using System;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace WUnit.Framework {
	[Serializable]
	public class TestAssertionException : Exception {
		public TestAssertionException() { }

		public TestAssertionException(string message, Exception inner)
			: base(null, inner) {
			_message = message;
		}

		public TestAssertionException(string message) {
			_message = message;
		}

		protected TestAssertionException(
			SerializationInfo info,
			StreamingContext context)
			: base(info, context) { }

		string _message;
		public override string Message {
			get {
				return _message ?? "Assertion Failed";
			}
		}

		[SecurityPermission(SecurityAction.LinkDemand,Flags=SecurityPermissionFlag.SerializationFormatter)]
		public override void GetObjectData(SerializationInfo info, StreamingContext context) {
			if (info == null) throw new ArgumentNullException("info");
			info.AddValue("Message2", _message);
			base.GetObjectData(info, context);
		}

		public virtual TestResult TestResult {
			get {
				return TestResult.Fail;
			}
		}

	}
}